<script>
    $(document).ready(function() {
        $(".add-address").click(function() {
            $(this).parents(".infolist").hide();
            $(".address-form").show();
        })
    })
</script>
<div id="addresslist">
    <?php
    if ($address) {
        foreach ($address as $key => $value) {
            ?>
            <div class="infolist cols1 cl">
                <div class="col cl">
                    <div class="tit"><?php echo $value['recipients']; ?></div>
                    <div class="inp cl" style="width:890px;">
                        <div class="z"><?php echo $value['province']; ?><span class="pipe"></span><?php echo $value['city']; ?><span class="pipe"></span><?php echo $value['area']; ?><span class="pipe"></span><?php echo $value['street']; ?><span class="pipe"></span><?php echo $value['streetDetail']; ?><span class="lm18"><?php echo $value['mobile']; ?></span><span class="pipe"></span><?php echo $value['postalcode']; ?></div>
                        <div class="y">
                            <span class="rm50 c_b"><?php if ($value['defaultAddress'] == 1) { ?>默认地址<?php } ?></span><a href="<?php echo $value['id']; ?>" class="c_b">编辑</a><span class="pipe c_b">|</span><a href="#" class="c_b">删除</a>
                        </div>
                    </div>
                </div>
            </div>
            <?php
        }
        ?>
    </div>
    <div class="infolist cols1 cl clbd_b">
        <div class="col cl">
            <div class="tit"></div>
            <div class="inp cl"><a href="javascript:void(0);" class="c_b add-address">添加新地址</a></div>
        </div>
    </div>
    <?php
} else {
    ?>
    </div>
    <div class="infolist cols1 cl clbd_b">
        <div class="col cl">
            <div class="tit"></div>
            <div class="inp cl">暂无收货地址，马上<a href="javascript:void(0);" class="c_b add-address">添加新地址</a></div>
        </div>
    </div>
    <?php
}
?>
<div class="infolist clbd_b address-form zhbform" style="display: none;">
    <?php
    $this->breadcrumbs = $this->pageTitle = '地址管理';
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'address-form',
        'enableClientValidation' => true,
        'clientOptions' => array(
            'validateOnSubmit' => true,
        ),
    ));
    ?>
    <?php echo $form->errorSummary($model); ?>
    <div class="cols1 cl tm20">
        <div class="col cl">
            <div class="tit"><?php echo $form->labelEx($model, 'area'); ?></div>
            <div class="inp cl">
                <div class="select z">
                    <?php echo $form->dropDownList($model, 'province', array('1' => '2'), array('empty' => '选择省')); ?>
                </div>
                <div class="select z lm15">
                    <?php echo $form->dropDownList($model, 'city', array('1' => '2'), array('empty' => '选择市')); ?>
                </div>
                <div class="select z lm15">
                    <?php echo $form->dropDownList($model, 'area', array('1' => '2'), array('empty' => '选择区/县')); ?>
                </div>
                <div class="select z lm15">
                    <?php echo $form->dropDownList($model, 'street', array('1' => '2'), array('empty' => '街道')); ?>
                </div>
            </div>
        </div>
    </div>
    <div class="cols2 cl tm10">
        <div class="col cl">
            <div class="tit"><?php echo $form->labelEx($model, 'streetDetail'); ?></div>
            <div class="inp cl"><div class="text"><?php echo $form->textField($model, 'streetDetail', array('style' => 'width:365px')); ?><span></span></div></div>
        </div>
        <div class="col cl">
            <div class="tit"><?php echo $form->labelEx($model, 'postalcode'); ?></div>
            <div class="inp cl"><div class="text"><?php echo $form->textField($model, 'postalcode', array('style' => 'width:165px')); ?><span></span></div></div>
        </div>
    </div>
    <div class="cols1 cl tm10">
        <div class="col cl">
            <div class="tit"><?php echo $form->labelEx($model, 'recipients'); ?></div>
            <div class="inp cl"><div class="text"><?php echo $form->textField($model, 'recipients', array('style' => 'width:165px')); ?><span></span></div></div>
        </div>
    </div>
    <div class="cols1 cl tm10">
        <div class="col cl">
            <div class="tit"><?php echo $form->labelEx($model, 'mobile'); ?></div>
            <div class="inp cl"><div class="text"><?php echo $form->textField($model, 'mobile', array('style' => 'width:165px')); ?><span></span></div></div>
        </div>
    </div>
    <div class="cols1 cl tm10">
        <div class="col cl">
            <div class="tit"><?php echo $form->labelEx($model, 'telephone'); ?></div>
            <div class="inp cl"><div class="z"><div class="text"><?php echo $form->textField($model, 'areacode', array('style' => 'width:70px', 'placeholder' => '区号')); ?><span></span></div></div><div class="z lm18"><div class="text"><?php echo $form->textField($model, 'phonenum', array('style' => 'width:153px', 'placeholder' => '座机号码')); ?><span></span></div></div><div class="z lm18"><div class="text"><?php echo $form->textField($model, 'extension', array('style' => 'width:70px', 'placeholder' => '分机号')); ?><span></span></div></div></div>
        </div>
    </div>
    <div class="cols1 cl tm10">
        <div class="col cl">
            <div class="tit"></div>
            <div class="inp cl">
                <div class="z"><?php echo $form->checkBox($model, 'default'); ?><?php echo $form->label($model, 'default'); ?></div>
                <?php echo CHTML::ajaxSubmitButton('添加', Yii::app()->baseUrl . '/ajax/?mod=addUserContactInfo', array('dataType' => 'html', 'success' => 'js:function(data){$("#ajaxwaitid").html(data);}'), array('class' => 'submit submit_green z', 'style' => 'margin-left:20px;')) ?>
                <div class="z"><?php echo $form->error($model, 'postalcode'); ?></div>
            </div>
        </div>
    </div>
    <?php $this->endWidget(); ?>
</div>